package com.jwdf.uda.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.jwdf.uda.R;
import com.jwdf.uda.ui.fragment.base.BaseFragment;
import com.jwdf.uda.ui.fragment.user.personal.SetCoverFragment;

/**
 * Created by Administrator on 2016/9/26.
 */
public class SetCoverActivity extends AbsTitleBarActivity {
    private static final String EXTRA_PHOTO = "photo";

    public static void start(Context context, String avatar) {
        Intent intent = new Intent(context, SetCoverActivity.class);
        intent.putExtra(EXTRA_PHOTO, avatar);
        context.startActivity(intent);
    }

    @Override
    protected String getTopTitle() {
        return getString(R.string.account_cover);
    }

    @Override
    protected BaseFragment onCreateContentFragment() {
        return new SetCoverFragment();
    }

    @Override
    protected Bundle onPutArguments() {
        Bundle args = new Bundle();
        args.putString(EXTRA_PHOTO, getIntent().getStringExtra(EXTRA_PHOTO));
        return args;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        EventBusUtil.registerEvent(this);
    }

    @Override
    protected void onDestroy() {
//        EventBusUtil.unregisterEvent(this);
        super.onDestroy();
    }

//    public void onEvent(IndividualEvent event) {
//        finish();
//    }

//    @Override
//    public void onHeadBackClick(View view) {
//        //        EventBusUtil.post(new MessageNoticeEvent(MessageNoticeEvent.READ_ALL_MESSAGE));
//        UdaUtils.hideInputMethod(this, view);
//        FragmentManager manager = getSupportFragmentManager();
//        int count = manager.getBackStackEntryCount();
//        if(count == 0) {
//            showConfirm();
//        } else {
//            try {
//                manager.popBackStackImmediate();
//            } catch(IllegalStateException ignored) {
//            }
//        }
//    }
//
//    @Override
//    public boolean onKeyDown(int keyCode, KeyEvent event) {
//        if(keyCode == KeyEvent.KEYCODE_BACK) {
//            FragmentManager manager = getSupportFragmentManager();
//            int count = manager.getBackStackEntryCount();
//            if(count == 0) {
//                showConfirm();
//            }
//        }
//        return super.onKeyDown(keyCode, event);
//    }
//    private void showConfirm() {
//        EventBusUtil.post(new CoverEvent(CoverEvent.EVENT_COVER_CLOSE));
//    }
}
